//
//  ProgressHUDManager.swift
//  imember_printer
//
//  Created by feibi on 2022/1/17.
//

import UIKit
import SVProgressHUD

class ProgressHUDManager: NSObject {
    class func showLoading(message: String? = nil) {
        SVProgressHUD.setDefaultStyle(.dark)
        SVProgressHUD.setDefaultMaskType(.none)
        SVProgressHUD.show(withStatus: message)
    }
    
    class func showSuccess(message: String?, dismissDelay: TimeInterval = 1.5) {
        SVProgressHUD.setDefaultStyle(.dark)
        SVProgressHUD.setDefaultMaskType(.none)
        SVProgressHUD.showSuccess(withStatus: message)
        SVProgressHUD.dismiss(withDelay: dismissDelay)
    }
    
    class func showInfo(message: String?, dismissDelay: TimeInterval = 1.5) {
        SVProgressHUD.setDefaultStyle(.dark)
        SVProgressHUD.setDefaultMaskType(.none)
        SVProgressHUD.showInfo(withStatus: message)
        SVProgressHUD.dismiss(withDelay: dismissDelay)
    }
    
    class func showError(message: String?, dismissDelay: TimeInterval = 1.5) {
        SVProgressHUD.setDefaultStyle(.dark)
        SVProgressHUD.setDefaultMaskType(.none)
        SVProgressHUD.showError(withStatus: message)
        SVProgressHUD.dismiss(withDelay: dismissDelay)
    }
    
    class func dismiss() {
        if SVProgressHUD.isVisible() {
            SVProgressHUD.popActivity()
        }
    }
}
